﻿using LiteBlog.Common.Entities;
using LiteBlog.Repositories.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LiteBlog.Components.SiteMap
{
    internal class PostProvider : ISiteMapProvider
    {
        internal PostProvider(IBlogRepository blogRepo)
        {
            _blogRepo = blogRepo;
        }
        public IEnumerable<SiteMapUrl> GetSiteMapItems()
        {
            return _blogRepo.GetPublished()
                .Select(postInfo => new SiteMapUrl
                {
                    Location = "/Post/" + postInfo.FileID,
                    LastModifiedTime = postInfo.Time
                });
        }

        private IBlogRepository _blogRepo;
    }
}
